home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 November: Tool Chest / Dev.CD Nov 96 TC / Dev.CD Nov 96 TC.toast / Tool Chest / Development Tools & Languages / HyperCard Related / APDA HyperCard Toolkits / HyperCard Video Toolkit 2.0 / HVT #2 / Advanced Material / Video Sources / playVideo.p < prev    next >
Encoding:
Text File  |  1995-02-07  |  2.9 KB  |  115 lines  |  [TEXT/MPS ]

  1. (*
  2.     playVideo first,last - Play the frames from first to last, at a speed given in
  3.         the global videoSpeed, using blanking to the first frame if the global
  4.         blankNextVideo is set to true.
  5.  
  6.     To compile and link this file using Macintosh Programmer's Workshop,
  7.  
  8.         pascal -w playVideo.p
  9.  
  10.         link -m ENTRYPOINT -o HyperCommands -rt XCMD=8002 -sn Main=playVideo ∂
  11.             playVideo.p.o "{MPW}"Libraries:interface.o "{MPW}"PLibraries:PasLib.o
  12.  
  13.     Copyright © 1987,88 Apple Computer, Inc.
  14.  
  15.     9/87 - Initial coding by Harry R. Chesley.
  16.     2/88 - Updated to new specification by Harry R. Chesley.
  17. *)
  18.  
  19. {$R-}
  20.  
  21. {$S playVideo }     { Segment name must be the same as the command name. }
  22.  
  23. unit DummyUnit;
  24.  
  25. interface
  26.  
  27. uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
  28.  
  29. procedure EntryPoint(paramPtr: XCmdPtr);
  30.     
  31. implementation
  32.  
  33. type
  34.  
  35. Str31 = String[31];
  36.  
  37. procedure playVideo(paramPtr: XCmdPtr); forward;
  38.  
  39. procedure EntryPoint(paramPtr: XCmdPtr);
  40.  
  41.     begin
  42.         playVideo(paramPtr);
  43.     end;
  44.  
  45. procedure playVideo(paramPtr: XCmdPtr);
  46.  
  47.     var numberOfParms: integer;        { Number of parameters on the command. }
  48.         firstFrame: str255;                    { First frame number. }
  49.         lastFrame: str255;                    { Last frame number. }
  50.         fps: str255;                                { Frames-per-second. }
  51.         str: str255;
  52.  
  53.     {$I XCmdGlue.inc}
  54.  
  55.     procedure Fail(errMsg: Str255); { set theResult and quit }
  56.         begin
  57.             paramPtr^.returnValue := PasToZero(errMsg);
  58.             exit(playVideo);
  59.         end;
  60.  
  61.     {$I VideoUtil.inc}
  62.  
  63.     begin
  64.         numberOfParms := paramPtr^.paramCount;
  65.         if numberOfParms > 2 then Fail('parameter count is not 0-2');
  66.  
  67.         { Get the first frame number. }
  68.         if numberOfParms > 0 then
  69.             begin
  70.                 GetStrParm(1,firstFrame);
  71.                 { Weed out special cases, so the drivers don't have to. }
  72.                 if firstFrame = '' then firstFrame := 'here'
  73.                 else if (not StringEqual(firstFrame,'here')) and (StrToNum(firstFrame) < 0) then firstFrame := '0';
  74.             end
  75.         else firstFrame := 'here';
  76.  
  77.         { Get the last frame number. }
  78.         if numberOfParms > 1 then
  79.             begin
  80.                 GetStrParm(2,lastFrame);
  81.                 { Weed out special cases. }
  82.                 if lastFrame = '' then lastFrame := 'lastFrame'
  83.                 else if not StringEqual(lastFrame,'lastFrame') then
  84.                     begin
  85.                         GetStrGlobal('videoMode',str);
  86.                         if StringEqual(str,'chapterMode') then
  87.                             begin
  88.                                 if StrToNum(lastFrame) < 0 then lastFrame := '0';
  89.                             end
  90.                         else if StrToNum(lastFrame) <= 1 then lastFrame := '0';
  91.                     end;
  92.             end
  93.         else lastFrame := 'lastFrame';
  94.         { Remember what we're playing to. }
  95.         if StringEqual(lastFrame,'lastFrame') then SetStrGlobal('lastVideoFrame','54000')
  96.         else SetStrGlobal('lastVideoFrame',lastFrame);
  97.  
  98.         { Make sure the speed is there. }
  99.         GetStrGlobal('videoSpeed',fps);
  100.         if fps = '' then
  101.             begin
  102.                 fps := '30';
  103.                 SetStrGlobal('videoSpeed',fps);
  104.             end;
  105.  
  106.         { Call the player-specific driver to actually do it. }
  107.         videoCmd('play',Concat(firstFrame,',',lastFrame));
  108.  
  109.         { Clear out the speed and blanking globals. }
  110.         SetStrGlobal('videoSpeed','');
  111.         SetStrGlobal('blankNextVideo','');
  112.     end;
  113.  
  114. end.
  115.